﻿//-----------------------------------------------------------------------
// <copyright file="Void.cs" company="tuliprules.org">
//     Copyright (c) 2010 tuplelister, tuliprules.org.
// </copyright>
// <summary>This is the Void class.</summary>
//-----------------------------------------------------------------------

namespace Tulip.Rules
{
    using System;

    /// <summary>
    /// Represents a void.   This class is used to implement tuple classes.
    /// </summary>
    internal class Void : IComparable
    {
        #region IComparable Members

        /// <summary>
        /// Tests to see if two Void objects provided are equal.
        /// </summary>
        /// <param name="voidA">First Void.</param>
        /// <param name="voidB">Second Void.</param>
        /// <returns>
        /// Always returns true.  Two voids are always treated
        /// as identical.
        /// </returns>
        public static bool operator ==(Void voidA, Void voidB)
        {
            return true;
        }

        /// <summary>
        /// Tests to see if two Void objects provided are not equal.
        /// </summary>
        /// <param name="voidA">First Void.</param>
        /// <param name="voidB">Second Void.</param>
        /// <returns>
        /// Always returns false.  Two voids are always treated
        /// as identical.
        /// </returns>
        public static bool operator !=(Void voidA, Void voidB)
        {
            return false;
        }

        /// <summary>
        /// LT operator.
        /// </summary>
        /// <param name="voidA">First Void.</param>
        /// <param name="voidB">Second Void.</param>
        /// <returns>
        /// Always returns false.  Two voids are always treated
        /// as identical.
        /// </returns>
        public static bool operator >(Void voidA, Void voidB)
        {
            return false;
        }

        /// <summary>
        /// GT operator.
        /// </summary>
        /// <param name="voidA">First Void.</param>
        /// <param name="voidB">Second Void.</param>
        /// <returns>
        /// Always returns false.  Two voids are always treated
        /// as identical.
        /// </returns>
        public static bool operator <(Void voidA, Void voidB)
        {
            return false;
        }

        /// <summary>
        /// Camprison method.
        /// </summary>
        /// <param name="obj">Object to be compared.</param>
        /// <returns>Returns 0 if the compared object is a Void.   Otherwise, always return a negative number.</returns>
        public int CompareTo(object obj)
        {
            return (obj is Void) ? 0 : -1;
        }

        /// <summary>
        /// Tests to see if the object provided is equal to this Void.
        /// </summary>
        /// <param name="obj">The object to compare.</param>
        /// <returns>True if equal, otherwise false.</returns>
        public override bool Equals(object obj)
        {
            // Two Void objects are always equal
            return true;
        }

        /// <summary>
        /// Returns the hashcode for the Void.
        /// </summary>
        /// <returns>A void always returns an identical hashcode</returns>
        public override int GetHashCode()
        {
            return 322938479;
        }

        #endregion
    }
}